﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Wizard.UI;
using System.IO;

namespace DVRMS_Renamer
{
    public partial class wizPage3 : Wizard.UI.InternalWizardPage
    {
        private frmMain mobjOwnerForm;

        public wizPage3(frmMain OwnerForm)
        {
            InitializeComponent();

            mobjOwnerForm = OwnerForm;
        }

        private void wizPage3_WizardPageSetActive(object sender, System.ComponentModel.CancelEventArgs e)
        {
            SetWizardButtons(WizardButtons.Next);
        }

        private void wizPage3_WizardPageActivated(object sender, EventArgs e)
        {
            this.Refresh();
            FormLayout(Globals.FormLayouts.flProgress);
            Common.LoadDVRMSFiles(this, pgrProgress, lblWorking, lstItems);
            FormLayout(Globals.FormLayouts.flStandard);
        }

        private void wizPag3_Load(object sender, EventArgs e)
        {
            lstItems.FullRowSelect = true;
            lstItems.View = View.Details;
            lstItems.HeaderStyle = ColumnHeaderStyle.Nonclickable;
            lblWorking.Text = "Working...";

            ColumnHeader col1 = new ColumnHeader();
            ColumnHeader col2 = new ColumnHeader();
            ColumnHeader col3 = new ColumnHeader();
            ColumnHeader col4 = new ColumnHeader();
            ColumnHeader col5 = new ColumnHeader();

            col1.Text = "File";
            col2.Text = "Series Title";
            col3.Text = "Original Broadcast";
            col4.Text = "Sub Title";
            col5.Text = "Sub Title Description";

            lstItems.Columns.AddRange(new ColumnHeader[] { col1, col2, col3, col4, col5 });
        }

        private void wizPage3_WizardNext(object sender, WizardPageEventArgs e)
        {
            Globals.selectedFilesToScan.Clear();

            for (int i = 0; i < lstItems.CheckedItems.Count; i++)
            {
                File theFile = (File)lstItems.CheckedItems[i].Tag;
                Globals.selectedFilesToScan.Add(theFile);
            }
        }

        private void FormLayout(Globals.FormLayouts fl)
        {
            lblWorking.Visible = (fl == Globals.FormLayouts.flProgress);
            pgrProgress.Visible = (fl == Globals.FormLayouts.flProgress);
            lstItems.Visible = (fl == Globals.FormLayouts.flStandard);

            if (fl == Globals.FormLayouts.flProgress)
            {
                Banner.Title = "Scanning";
                Banner.Subtitle = "Scanning your folder for DVR-MS files and reading the details from the files";
            }
            else
            {
                Banner.Title = "Select Files";
                Banner.Subtitle = "Select which files you would like to try and rename from thetvdb.com";
            }
        }
    }
}
